import { request } from 'ice';

// 列表
export function getAccountsPage(pageParams: ICommon.PageParams, formData: CategoryState.QueryParams) {
  const params = {
    ...pageParams,
    ...formData,
  };
  return request.get('/seller/account/list', { params }).then((res) => ({
    total: res?.total || 0,
    list: res?.data || [],
  }));
}

interface EnableParams {
  sellerId: number;
  block: boolean;
}

// 禁用、启用
export function enableStatus(params: EnableParams) {
  return request.get('/seller/account/block', { params });
}

// 删除
export function deleteAccount(sellerId: number) {
  return request.get('/seller/account/delete', { params: { sellerId } });
}

interface SaveParams {
  // 卖家id
  id: number;
  // 卖家名称
  nickName: string;
  // 邮箱地址
  email: string;
  // 电话
  telephone: string;
  // 地址
  address: string;
  // 费率
  rate: number;
  // 卖家等级
  level: number;
}

// 新增、编辑
export async function createSellerAccounts(data: SaveParams) {
  return await request.post('/seller/account/save', data);
}
